#include<bits/stdc++.h>
using namespace std;
#define int long long
const long long maxn=100005;
struct car{
    int d,v,a;
};
car c[maxn];
int n,m,L,V;
int p[maxn];
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    scanf("%lld",&T);
    while(T--){
        scanf("%lld%lld%lld%lld",&n,&m,&L,&V);
        for(int i=1;i<=n;i++){
            scanf("%lld%lld%lld",&c[i].d,&c[i].v,&c[i].a);
        }
        for(int i=1;i<=m;i++){
            scanf("%lld",&p[i]);
        }
        cout<<(n+1)/2<<" "<<(m+1)/2<<endl;
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
